import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;

public class GameOverScene {
    private GameManager gameManager;
    private static final int WIDTH = 400;
    private static final int HEIGHT = 600;

    public GameOverScene(GameManager gameManager) {
        this.gameManager = gameManager;
    }

    public Scene createScene(int score) {
        VBox root = new VBox(20);
        root.setStyle("-fx-background-color: #222222; -fx-alignment: center;");
        root.setPadding(new javafx.geometry.Insets(50));

        Text gameOverText = new Text("游戏结束");
        gameOverText.setFont(Font.font("Arial", 40));
        gameOverText.setFill(javafx.scene.paint.Color.RED);

        Text scoreText = new Text("最终分数: " + score);
        scoreText.setFont(Font.font("Arial", 24));
        scoreText.setFill(javafx.scene.paint.Color.WHITE);

        Button restartButton = new Button("重新开始");
        restartButton.setPrefSize(200, 50);
        restartButton.setFont(Font.font("Arial", 16));
        restartButton.setOnAction(e -> gameManager.startGame());

        Button menuButton = new Button("返回主菜单");
        menuButton.setPrefSize(200, 50);
        menuButton.setFont(Font.font("Arial", 16));
        menuButton.setOnAction(e -> gameManager.showMainMenu());

        root.getChildren().addAll(gameOverText, scoreText, restartButton, menuButton);

        return new Scene(root, WIDTH, HEIGHT);
    }
}
